package com.sprite.htr.spritehtr.view;

import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ListView;

import com.sprite.htr.spritehtr.R;
import com.sprite.htr.spritehtr.adapter.ChongZhiAdapter;
import com.sprite.htr.spritehtr.bean.ChongZhiInfo;
import com.sprite.htr.spritehtr.util.AnimUtil;

import java.util.ArrayList;

/**
 * Created by Administrator on 2017/7/2.
 */
public class ChongZhiView extends BaseView{
    private Dialog dialog;
    private ImageView iv_close;
    private ImageView iv_cz;
    private ListView lv_cz;

    public ChongZhiView(Context context) {
        super(context);
        setContentView(R.layout.chongzhi);

        initUI();
        initLvCSAdapter();
    }

    @Override
    protected void initUI() {
        iv_close = (ImageView) findViewById(R.id.iv_close);
        AnimUtil.addOnTouchListener(iv_close, 0.5f, 0.5f, new AnimUtil.AnimListener() {
            @Override
            public void down(View v) {

            }

            @Override
            public void move(View v) {

            }

            @Override
            public void up(View v) {
                dialog.dismiss();
            }
        });

        iv_cz = (ImageView) findViewById(R.id.iv_cz);
        AnimUtil.addOnTouchListener(iv_cz, 0.5f, 0.5f, null);

        lv_cz = (ListView) findViewById(R.id.lv_chongzhi);
    }

    private void initLvCSAdapter(){
        ChongZhiAdapter adapter = new ChongZhiAdapter(context, new ArrayList<ChongZhiInfo>());
        lv_cz.setAdapter(adapter);
    }

    public void show(){
        if (dialog == null){
            dialog = new Dialog(context, R.style.MyDialog);
            FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(-2, -2);
            dialog.setContentView(view, params);
        }

        dialog.show();
    }

}

